home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:h="http://www.w3.org/1999/xhtml"
- xmlns:w2x="urn:schemas-docsoft-com:word-to-xml:extensions"
- xmlns:o="urn:schemas-microsoft-com:office:office"
- exclude-result-prefixes="h w2x o">
-
- <xsl:output method="xml" encoding="utf-8" indent="yes"
- omit-xml-declaration="no" />
-
- <xsl:template match="h:style|h:script|h:xml" />
- <xsl:template match="w2x:hide|w2x:script" />
-
- <xsl:template match="/">
- <article>
- <articleinfo>
- <title>
- <xsl:for-each select="h:html/h:head/h:title">
- <xsl:value-of select="." />
- </xsl:for-each>
- </title>
- <xsl:apply-templates select="//o:documentproperties" />
- </articleinfo>
- <xsl:apply-templates select="h:html/h:body" />
- </article>
- </xsl:template>
- <xsl:template match="o:documentproperties">
- <xsl:if test="o:author">
- <author>
- <xsl:choose>
- <xsl:when test="contains(o:author, ' ')">
- <firstname>
- <xsl:value-of select="substring-before(o:author, ' ')" />
- </firstname>
- <surname>
- <xsl:value-of select="substring-after(o:author, ' ')" />
- </surname>
- </xsl:when>
- <xsl:otherwise>
- <othername>
- <xsl:value-of select="o:author" />
- </othername>
- </xsl:otherwise>
- </xsl:choose>
- </author>
- </xsl:if>
- <xsl:if test="o:company">
- <corpname>
- <xsl:value-of select="o:company" />
- </corpname>
- </xsl:if>
- <xsl:if test="o:lastsaved">
- <date>
- <xsl:value-of select="o:lastsaved" />
- </date>
- </xsl:if>
- </xsl:template>
- <xsl:template match="h:body">
- <xsl:apply-templates />
- </xsl:template>
- <xsl:template match="h:div[parent::h:body]">
- <section>
- <xsl:apply-templates />
- </section>
- </xsl:template>
- <xsl:template match="h:p">
- <para>
- <xsl:apply-templates />
- </para>
- </xsl:template>
- <xsl:template match="h:ol|h:div[attribute::w2x:list-type]">
- <orderedlist>
- <xsl:apply-templates />
- </orderedlist>
- </xsl:template>
- <xsl:template match="h:ul|h:div[attribute::w2x:list-type = 'bullet']">
- <itemizedlist>
- <xsl:apply-templates />
- </itemizedlist>
- </xsl:template>
- <xsl:template match="h:span[attribute::w2x:list-item-number]" />
- <xsl:template match="h:li|h:*[attribute::w2x:list-item-class]">
- <listitem>
- <xsl:for-each select="*|text()">
- <xsl:choose>
- <xsl:when test="not(self::h:span or self::text())">
- <xsl:apply-templates select="." />
- </xsl:when>
- <xsl:when test="normalize-space(.) = ''" />
- <xsl:otherwise>
- <para><xsl:apply-templates select="." /></para>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </listitem>
- </xsl:template>
- <xsl:template match="h:img">
- <figure>
- <title><xsl:value-of select="attribute::alt" /></title>
- <graphic fileref="{attribute::src}"/>
- </figure>
- </xsl:template>
- <xsl:template match="h:a">
- <anchor id="{attribute::name}" />
- </xsl:template>
- <xsl:template match="h:a[attribute::href]">
- <ulink url="{attribute::href}">
- <xsl:apply-templates />
- </ulink>
- </xsl:template>
- <xsl:template match="h:a[starts-with(attribute::href, '#')]">
- <link linkend="{substring-after(attribute::href, '#')}">
- <xsl:apply-templates />
- </link>
- </xsl:template>
- <xsl:template match="h:b|h:i|h:strong">
- <emphasis>
- <xsl:apply-templates />
- </emphasis>
- </xsl:template>
- <xsl:template match="h:table">
- <table>
- <xsl:if test="h:caption">
- <title>
- <xsl:value-of select="h:cation" />
- </title>
- </xsl:if>
- <xsl:variable name="cols"><xsl:apply-templates select=".//h:tr[1]/*[position() = last()]" mode="count-cols-before" /></xsl:variable>
- <tgroup cols="{$cols}">
- <xsl:call-template name="print-cols">
- <xsl:with-param name="col" select="number($cols)" />
- </xsl:call-template>
- <tbody>
- <xsl:apply-templates />
- </tbody>
- </tgroup>
- </table>
- </xsl:template>
- <xsl:template name="print-cols">
- <xsl:param name="col" />
- <xsl:if test="$col > 0">
- <xsl:call-template name="print-cols">
- <xsl:with-param name="col" select="$col - 1" />
- </xsl:call-template>
- <colspec colname="c{$col}" />
- </xsl:if>
- </xsl:template>
- <xsl:template match="*" mode="count-cols-before">
- <xsl:variable name="cols-before"><xsl:apply-templates select="preceding-sibling::*[1]" mode="count-cols-before" /></xsl:variable>
- <xsl:choose>
- <xsl:when test="attribute::colspan != '' and $cols-before != ''">
- <xsl:value-of select="number($cols-before) + number(attribute::colspan)" />
- </xsl:when>
- <xsl:when test="attribute::colspan != ''">
- <xsl:value-of select="number(attribute::colspan)" />
- </xsl:when>
- <xsl:when test="$cols-before != ''">
- <xsl:value-of select="number($cols-before) + 1" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="1" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="h:tr">
- <row>
- <xsl:apply-templates />
- </row>
- </xsl:template>
- <xsl:template match="h:td|h:th">
- <entry>
- <xsl:if test="attribute::rowspan != ''">
- <xsl:attribute name="morerows">
- <xsl:value-of select="number(attribute::rowspan) - 1" />
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="attribute::colspan != ''">
- <xsl:variable name="cols-before">
- <xsl:apply-templates select="preceding-sibling::*[1]" mode="count-cols-before" />
- </xsl:variable>
- <xsl:attribute name="namest">c<xsl:value-of select="number($cols-before) + 1" /></xsl:attribute>
- <xsl:attribute name="nameend">c<xsl:value-of select="number($cols-before) + number(attribute::colspan)" /></xsl:attribute>
- </xsl:if>
- <xsl:if test="attribute::align != ''">
- <xsl:attribute name="align">
- <xsl:value-of select="attribute::align" />
- </xsl:attribute>
- </xsl:if>
- <xsl:apply-templates />
- </entry>
- </xsl:template>
-
- <xsl:template match="h:div[attribute::w2x:header-level]">
- <section>
- <sectioninfo>
- <title><xsl:apply-templates select="*[1]" mode="title" /></title>
- </sectioninfo>
- <xsl:apply-templates />
- </section>
- </xsl:template>
-
- <xsl:template match="h:h1|h:h2|h:h3|h:h4|h:h5" />
-
- <xsl:template match="*" mode="title" />
- <xsl:template match="h:h1|h:h2|h:h3|h:h4|h:h5" mode="title">
- <xsl:value-of select="." />
- </xsl:template>
-
- </xsl:stylesheet>
-